package com.molyfun.parents.activity.report.adapter;

import android.content.Context;
import android.support.v4.app.FragmentManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.molyfun.parents.R;
import com.molyfun.parents.activity.report.view.ReportFeedbackView;
import com.molyfun.parents.rest.bean.ReportFeedbackListResponse;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by william(liuchao.hit@gmail.com).
 * Date:9/19/16.
 * 课程
 */
public class ReportFeedbackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private Context mContext;
    private String mReportTimeInterval;

    private List<ReportFeedbackListResponse.ReportFeedbackBean> mDataList;
    private FragmentManager mFragmentManager;

    public ReportFeedbackListAdapter(Context mContext, FragmentManager fragmentManager) {
        this.mContext = mContext;
        this.mFragmentManager = fragmentManager;
    }

    public void initData(List<ReportFeedbackListResponse.ReportFeedbackBean> reportFeedbackBeanList, String reportTimeInterval) {
        this.mDataList = reportFeedbackBeanList;
        this.mReportTimeInterval = reportTimeInterval;
        notifyDataSetChanged();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ReportDetailCellViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_report_feedback_cell, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ReportDetailCellViewHolder reportDetailCellViewHolder = (ReportDetailCellViewHolder) holder;
        reportDetailCellViewHolder.mReportFeedbackView.initData(mDataList.get(position), mFragmentManager);
    }


    @Override
    public int getItemCount() {
        if (mDataList == null) {
            return 0;
        }
        return mDataList.size();
    }

    class ReportDetailCellViewHolder extends RecyclerView.ViewHolder {

        @InjectView(R.id.report_feedback_layout)
        ReportFeedbackView mReportFeedbackView;

        public ReportDetailCellViewHolder(View view) {
            super(view);
            ButterKnife.inject(this, view);
        }
    }

    class ReportDetailHeaderViewHolder extends RecyclerView.ViewHolder {

        @InjectView(R.id.time_interval)
        TextView mTimeInterval;

        public ReportDetailHeaderViewHolder(View view) {
            super(view);
            ButterKnife.inject(this, view);
        }
    }

}
